/**
 * 
 */
package com.imonsoft.common.html;

import java.io.Serializable;

/**
 * 
 * @author LiQianHui
 * @date 2013-04-17
 * @version 2013
 */
public class Radio implements Serializable {

	private static final long serialVersionUID = 8910920631623148314L;
	private String name;// HTML property:name
	private boolean checked = false;
	private String text;
	private String value;

	public Radio(String name, String value, String text, boolean checked) {
		this.name = name != null ? name : "";
		this.value = value;
		this.text = text;
		this.checked = checked;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param checked
	 *            the checked to set
	 */
	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	/**
	 * @param text
	 *            the text to set
	 */
	public void setText(String text) {
		this.text = text;
	}

	/**
	 * @param value
	 *            the value to set
	 */
	public void setValue(String value) {
		this.value = value;
	}

	@Override
	public String toString() {
		if (checked) {
			return "<label for='" + name + value + "'>" + text + "<input type='radio' id='" + name
					+ value + "' name='" + name + "' value='" + value + "' checked/></label>";
		} else {
			return "<label for='" + name + value + "'>" + text + "<input type='radio' id='" + name
					+ value + "' name='" + name + "' value='" + value + "'/></label>";
		}
	}
}
